package com.luocj.muke.demo.activity;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.luocj.muke.demo.R;
import com.luocj.muke.demo.adapter.ViewPagerAdapter;
import com.luocj.muke.demo.fragment.FragmentA;
import com.luocj.muke.demo.fragment.FragmentB;
import com.luocj.muke.demo.fragment.FragmentC;
import com.luocj.muke.demo.fragment.FragmentD;
import com.luocj.muke.demo.fragment.FragmentE;

import java.util.ArrayList;

public class LazyloadActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lazyload);
        initView();
    }

    private void initView() {
        FragmentA fragmentA = new FragmentA();
        FragmentB fragmentB = new FragmentB();
        FragmentC fragmentC = new FragmentC();
        FragmentD fragmentD = new FragmentD();
        FragmentE fragmentE = new FragmentE();
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(fragmentA);
        fragments.add(fragmentB);
        fragments.add(fragmentC);
        fragments.add(fragmentD);
        fragments.add(fragmentE);
        ViewPager viewpager = findViewById(R.id.viewpager);
        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments);
        viewpager.setAdapter(adapter);

    }
}
